#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/12 22:42
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : addlog_page.py
# @Project : crm
"""添加日志页面"""
from selenium.webdriver.common.by import By
from utils.util import HS3
from page.base_page import BasePage
class AddLog(BasePage):
    url = "{}/crm3/index.php?m=log".format(HS3)
    """定义定位器"""
    log_title_locator = (By.CSS_SELECTOR, 'input[name="subject"]')  # 日志标题
    log_content_locator = (By.XPATH, '/html/body')  # 日志内容
    log_submit_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]')  # 日志的保存按钮
    """具体操作"""
    def log_title(self,title):
        """输入标题"""
        self.driver.find_element(*self.log_title_locator).send_keys(title)
    def clear_title(self):
        """清除标题"""
        self.driver.find_element(*self.log_title_locator).clear()
    def log_content(self,content):
        """输入内容"""
        self.driver.find_element(*self.log_content_locator).send_keys(content)
    def clear_content(self):
        """清除内容"""
        self.driver.find_element(*self.log_content_locator).clear()
    def frame_to(self):
        """切换页面到内容输入框"""
        self.driver.switch_to.frame(self.driver.find_element_by_class_name('ke-edit-iframe'))
    def parent_to(self):
        """切换页面到最外层"""
        self.driver.switch_to.parent_frame()
    def submit(self):
        """保存"""
        self.driver.find_element(*self.log_submit_locator).click()

